$(function () {
    var formalStudent_datagrid = $("#formalStudent_datagrid");
    var formalStudent_dialog = $("#formalStudent_dialog");
    var formalStudent_form = $("#formalStudent_form");
    var class_dialog = $("#class_dialog");
    var class_form = $("#class_form");
    formalStudent_datagrid.datagrid({
        url: '/charts/student.do',
        fit: true,
        fitColumns: true,
        columns: [[
            {field: 'groupTypes', title: '分组类型', width: 100,formatter: function (value) {
                if (value==1){
                    return '转班'
                }else if (value ==2){
                    return '留学'
                }else if (value==0){
                    return '在读'
                }else if (value==32){
                    return '微信'
                }else if (value==33){
                    return '支付宝'
                }else if (value==34){
                    return '网银'
                }else if (value==35){
                    return '借贷'
                }

            }},
            {field: 'AlreadyPay', title: '已付总款', width: 100},
            {field: 'UnPaid', title: '未付总款', width: 100}
        ]],
        singleSelect: true,
        rownumbers: true,
        pagination: true,
        toolbar: "#formalStudent_btns"
    });

    $("#start_date").datebox({
        onSelect : function(beginDate){
            $('#end_date').datebox().datebox('calendar').calendar({
                validator: function(date){
                    return beginDate<date;//<=
                }
            });
        }
    });

    $("#gy").combobox('select', 'fst.payment_type');

    var methodObj = {
        reload: function () {
            $("#start_date").datebox('clear');
            $("#end_date").datebox('clear');
            formalStudent_datagrid.datagrid('load');
        },
        query: function () {
            var keyword = $("[name=keyword]").val();
            var groupBy = $("[name=groupBy]").val();
            var beginDate = $("[name=beginDate]").val();
            var endDate = $("[name=endDate]").val();
            formalStudent_datagrid.datagrid('load', {
                keyword: keyword,
                beginDate:beginDate,
                endDate:endDate,
                groupBy:groupBy
            })
        }
    }
    $("a[data-cmd]").click(function () {
        var methodName = $(this).data('cmd');
        methodObj[methodName]();
    })
})



